home *** CD-ROM | disk | FTP | other *** search
/ BMUG Newsletter 1996 Spring / S96 NL CD.iso / New NL PD Collections / Sound Manager 3.1 / For Programmers / Interfaces / SoundInput.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-24  |  10.8 KB  |  266 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        SoundInput.h
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9.      Bugs:        Report bugs to Radar component “System Interfaces”, “Latest”
  10.  
  11. */
  12.  
  13. #ifndef __SOUNDINPUT__
  14. #define __SOUNDINPUT__
  15.  
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20. /*    #include <ConditionalMacros.h>                                */
  21.  
  22. #ifndef __APPLEEVENTS__
  23. #include <AppleEvents.h>
  24. #endif
  25. /*    #include <Errors.h>                                            */
  26. /*    #include <Memory.h>                                            */
  27. /*        #include <MixedMode.h>                                    */
  28. /*    #include <OSUtils.h>                                        */
  29. /*    #include <Events.h>                                            */
  30. /*        #include <Quickdraw.h>                                    */
  31. /*            #include <QuickdrawText.h>                            */
  32. /*                #include <ScriptLayout.h>                        */
  33. /*    #include <EPPC.h>                                            */
  34. /*        #include <AppleTalk.h>                                    */
  35. /*        #include <Files.h>                                        */
  36. /*            #include <Finder.h>                                    */
  37. /*        #include <PPCToolbox.h>                                    */
  38. /*        #include <Processes.h>                                    */
  39. /*    #include <Notification.h>                                    */
  40. /*        #include <Collections.h>                                */
  41. /*        #include <Kernel.h>                                        */
  42. /*            #include <MachineExceptions.h>                        */
  43. /*            #include <Timing.h>                                    */
  44.  
  45. #ifndef __WINDOWS__
  46. #include <Windows.h>
  47. #endif
  48. /*    #include <Controls.h>                                        */
  49. /*        #include <Appearance.h>                                    */
  50. /*        #include <TextObjects.h>                                */
  51. /*            #include <Unicode.h>                                */
  52. /*        #include <Menus.h>                                        */
  53. /*    #include <Drag.h>                                            */
  54. /*        #include <TextEdit.h>                                    */
  55. /*            #include <TextServices.h>                            */
  56. /*                #include <Components.h>                            */
  57. /*                #include <LocaleObjects.h>                        */
  58.  
  59. #ifndef __DIALOGS__
  60. #include <Dialogs.h>
  61. #endif
  62.  
  63. #ifndef __FILES__
  64. #include <Files.h>
  65. #endif
  66.  
  67. #ifndef __SOUND__
  68. #include <Sound.h>
  69. #endif
  70.  
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74.  
  75. #if PRAGMA_ALIGN_SUPPORTED
  76. #pragma options align=mac68k
  77. #endif
  78.  
  79. #if PRAGMA_IMPORT_SUPPORTED
  80. #pragma import on
  81. #endif
  82.  
  83.  
  84. enum {
  85.     siDeviceIsConnected            = 1,                            /*input device is connected and ready for input*/
  86.     siDeviceNotConnected        = 0,                            /*input device is not connected*/
  87.     siDontKnowIfConnected        = -1,                            /*can't tell if input device is connected*/
  88.     siReadPermission            = 0,                            /*permission passed to SPBOpenDevice*/
  89.     siWritePermission            = 1                                /*permission passed to SPBOpenDevice*/
  90. };
  91.  
  92. enum {
  93. /*Info Selectors for Sound Input Drivers*/
  94.     siActiveChannels            = 'chac',                        /*active channels*/
  95.     siActiveLevels                = 'lmac',                        /*active meter levels*/
  96.     siAGCOnOff                    = 'agc ',                        /*automatic gain control state*/
  97.     siAsync                        = 'asyn',                        /*asynchronous capability*/
  98.     siChannelAvailable            = 'chav',                        /*number of channels available*/
  99.     siCompressionAvailable        = 'cmav',                        /*compression types available*/
  100.     siCompressionFactor            = 'cmfa',                        /*current compression factor*/
  101.     siCompressionHeader            = 'cmhd',                        /*return compression header*/
  102.     siCompressionNames            = 'cnam',                        /*compression type names available*/
  103.     siCompressionType            = 'comp',                        /*current compression type*/
  104.     siContinuous                = 'cont',                        /*continous recording*/
  105.     siDeviceBufferInfo            = 'dbin',                        /*size of interrupt buffer*/
  106.     siDeviceConnected            = 'dcon',                        /*input device connection status*/
  107.     siDeviceIcon                = 'icon',                        /*input device icon*/
  108.     siDeviceName                = 'name',                        /*input device name*/
  109.     siHardwareBusy                = 'hwbs',                        /*sound hardware is in use*/
  110.     siInputGain                    = 'gain',                        /*input gain*/
  111.     siInputSource                = 'sour',                        /*input source selector*/
  112.     siInputSourceNames            = 'snam',                        /*input source names*/
  113.     siLevelMeterOnOff            = 'lmet',                        /*level meter state*/
  114.     siModemGain                    = 'mgai',                        /*modem input gain*/
  115.     siNumberChannels            = 'chan',                        /*current number of channels*/
  116.     siOptionsDialog                = 'optd',                        /*display options dialog*/
  117.     siPlayThruOnOff                = 'plth',                        /*playthrough state*/
  118.     siRecordingQuality            = 'qual',                        /*recording quality*/
  119.     siSampleRate                = 'srat',                        /*current sample rate*/
  120.     siSampleRateAvailable        = 'srav',                        /*sample rates available*/
  121.     siSampleSize                = 'ssiz',                        /*current sample size*/
  122.     siSampleSizeAvailable        = 'ssav',                        /*sample sizes available*/
  123.     siSetupCDAudio                = 'sucd',                        /*setup sound hardware for CD audio*/
  124.     siSetupModemAudio            = 'sumd',                        /*setup sound hardware for modem audio*/
  125.     siStereoInputGain            = 'sgai',                        /*stereo input gain*/
  126.     siTwosComplementOnOff        = 'twos',                        /*two's complement state*/
  127.     siVoxRecordInfo                = 'voxr',                        /*VOX record parameters*/
  128.     siVoxStopInfo                = 'voxs',                        /*VOX stop parameters*/
  129.     siCloseDriver                = 'clos',                        /*reserved for internal use only*/
  130.     siInitializeDriver            = 'init',                        /*reserved for internal use only*/
  131.     siPauseRecording            = 'paus',                        /*reserved for internal use only*/
  132.     siUserInterruptProc            = 'user',                        /*reserved for internal use only*/
  133. /*Qualities*/
  134.     siCDQuality                    = 'cd  ',                        /*44.1kHz, stereo, 16 bit*/
  135.     siBestQuality                = 'best',                        /*22kHz, mono, 8 bit*/
  136.     siBetterQuality                = 'betr',                        /*22kHz, mono, MACE 3:1*/
  137.     siGoodQuality                = 'good'
  138. };
  139.  
  140. typedef struct SPB SPB, *SPBPtr;
  141.  
  142. /*user procedures called by sound input routines*/
  143. /*
  144.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  145.         be written in or called from a high-level language without the help of
  146.         mixed mode or assembly glue.
  147.  
  148.             typedef pascal void (*SIInterruptProcPtr)(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize);
  149.  
  150.         In:
  151.          => inParamPtr      A0.L
  152.          => dataBuffer      A1.L
  153.          => peakAmplitude    D0.W
  154.          => sampleSize      D1.L
  155. */
  156. typedef pascal void (*SICompletionProcPtr)(SPBPtr inParamPtr);
  157.  
  158. #if GENERATINGCFM
  159. typedef UniversalProcPtr SIInterruptUPP;
  160. typedef UniversalProcPtr SICompletionUPP;
  161. #else
  162. typedef Register68kProcPtr SIInterruptUPP;
  163. typedef SICompletionProcPtr SICompletionUPP;
  164. #endif
  165.  
  166. struct SPB {
  167.     long                            inRefNum;                    /*reference number of sound input device*/
  168.     unsigned long                    count;                        /*number of bytes to record*/
  169.     unsigned long                    milliseconds;                /*number of milliseconds to record*/
  170.     unsigned long                    bufferLength;                /*length of buffer in bytes*/
  171.     Ptr                                bufferPtr;                    /*buffer to store sound data in*/
  172.     SICompletionUPP                    completionRoutine;            /*completion routine*/
  173.     SIInterruptUPP                    interruptRoutine;            /*interrupt routine*/
  174.     long                            userLong;                    /*user-defined field*/
  175.     OSErr                            error;                        /*error*/
  176.     long                            unused1;                    /*reserved - must be zero*/
  177. };
  178. /* SPBVersion() returns a NumVersion*/
  179. extern pascal unsigned long SPBVersion(void)
  180.  FOURWORDINLINE(0x203C, 0x0000, 0x0014, 0xA800);
  181. extern pascal OSErr SndRecord(ModalFilterUPP filterProc, Point corner, OSType quality, SndListHandle *sndHandle)
  182.  FOURWORDINLINE(0x203C, 0x0804, 0x0014, 0xA800);
  183. extern pascal OSErr SndRecordToFile(ModalFilterUPP filterProc, Point corner, OSType quality, short fRefNum)
  184.  FOURWORDINLINE(0x203C, 0x0708, 0x0014, 0xA800);
  185. extern pascal OSErr SPBSignInDevice(short deviceRefNum, ConstStr255Param deviceName)
  186.  FOURWORDINLINE(0x203C, 0x030C, 0x0014, 0xA800);
  187. extern pascal OSErr SPBSignOutDevice(short deviceRefNum)
  188.  FOURWORDINLINE(0x203C, 0x0110, 0x0014, 0xA800);
  189. extern pascal OSErr SPBGetIndexedDevice(short count, Str255 deviceName, Handle *deviceIconHandle)
  190.  FOURWORDINLINE(0x203C, 0x0514, 0x0014, 0xA800);
  191. extern pascal OSErr SPBOpenDevice(ConstStr255Param deviceName, short permission, long *inRefNum)
  192.  FOURWORDINLINE(0x203C, 0x0518, 0x0014, 0xA800);
  193. extern pascal OSErr SPBCloseDevice(long inRefNum)
  194.  FOURWORDINLINE(0x203C, 0x021C, 0x0014, 0xA800);
  195. extern pascal OSErr SPBRecord(SPBPtr inParamPtr, Boolean asynchFlag)
  196.  FOURWORDINLINE(0x203C, 0x0320, 0x0014, 0xA800);
  197. extern pascal OSErr SPBRecordToFile(short fRefNum, SPBPtr inParamPtr, Boolean asynchFlag)
  198.  FOURWORDINLINE(0x203C, 0x0424, 0x0014, 0xA800);
  199. extern pascal OSErr SPBPauseRecording(long inRefNum)
  200.  FOURWORDINLINE(0x203C, 0x0228, 0x0014, 0xA800);
  201. extern pascal OSErr SPBResumeRecording(long inRefNum)
  202.  FOURWORDINLINE(0x203C, 0x022C, 0x0014, 0xA800);
  203. extern pascal OSErr SPBStopRecording(long inRefNum)
  204.  FOURWORDINLINE(0x203C, 0x0230, 0x0014, 0xA800);
  205. extern pascal OSErr SPBGetRecordingStatus(long inRefNum, short *recordingStatus, short *meterLevel, unsigned long *totalSamplesToRecord, unsigned long *numberOfSamplesRecorded, unsigned long *totalMsecsToRecord, unsigned long *numberOfMsecsRecorded)
  206.  FOURWORDINLINE(0x203C, 0x0E34, 0x0014, 0xA800);
  207. extern pascal OSErr SPBGetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  208.  FOURWORDINLINE(0x203C, 0x0638, 0x0014, 0xA800);
  209. extern pascal OSErr SPBSetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  210.  FOURWORDINLINE(0x203C, 0x063C, 0x0014, 0xA800);
  211. extern pascal OSErr SPBMillisecondsToBytes(long inRefNum, long *milliseconds)
  212.  FOURWORDINLINE(0x203C, 0x0440, 0x0014, 0xA800);
  213. extern pascal OSErr SPBBytesToMilliseconds(long inRefNum, long *byteCount)
  214.  FOURWORDINLINE(0x203C, 0x0444, 0x0014, 0xA800);
  215. extern pascal OSErr SetupSndHeader(SndListHandle sndHandle, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, short baseNote, unsigned long numBytes, short *headerLen)
  216.  FOURWORDINLINE(0x203C, 0x0D48, 0x0014, 0xA800);
  217. extern pascal OSErr SetupAIFFHeader(short fRefNum, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, unsigned long numBytes, unsigned long numFrames)
  218.  FOURWORDINLINE(0x203C, 0x0B4C, 0x0014, 0xA800);
  219. enum {
  220.     uppSIInterruptProcInfo = kRegisterBased
  221.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(SPBPtr)))
  222.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(Ptr)))
  223.          | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(short)))
  224.          | REGISTER_ROUTINE_PARAMETER(4, kRegisterD1, SIZE_CODE(sizeof(long))),
  225.     uppSICompletionProcInfo = kPascalStackBased
  226.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SPBPtr)))
  227. };
  228.  
  229. #if GENERATINGCFM
  230. #define NewSIInterruptProc(userRoutine)        \
  231.         (SIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIInterruptProcInfo, GetCurrentArchitecture())
  232. #define NewSICompletionProc(userRoutine)        \
  233.         (SICompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSICompletionProcInfo, GetCurrentArchitecture())
  234. #else
  235. #define NewSIInterruptProc(userRoutine)        \
  236.         ((SIInterruptUPP) (userRoutine))
  237. #define NewSICompletionProc(userRoutine)        \
  238.         ((SICompletionUPP) (userRoutine))
  239. #endif
  240.  
  241. #if GENERATINGCFM
  242. #define CallSIInterruptProc(userRoutine, inParamPtr, dataBuffer, peakAmplitude, sampleSize)        \
  243.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIInterruptProcInfo, (inParamPtr), (dataBuffer), (peakAmplitude), (sampleSize))
  244. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  245.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSICompletionProcInfo, (inParamPtr))
  246. #else
  247. /* (*SIInterruptProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  248. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  249.         (*(userRoutine))((inParamPtr))
  250. #endif
  251.  
  252.  
  253. #if PRAGMA_IMPORT_SUPPORTED
  254. #pragma import off
  255. #endif
  256.  
  257. #if PRAGMA_ALIGN_SUPPORTED
  258. #pragma options align=reset
  259. #endif
  260.  
  261. #ifdef __cplusplus
  262. }
  263. #endif
  264.  
  265. #endif /* __SOUNDINPUT__ */
  266.